package net.crowdloud.server.DatabaseAccess.groups;

import java.util.List;

import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;

public class GetGroups {

	public static Groups get(PersistenceManager persistenceManager) {

		Extent extent = persistenceManager.getExtent(Groups.class, true);

		Query query = persistenceManager.newQuery(extent);

		List<Groups> groupsDatabase = (List<Groups>) query.execute("");

		if (groupsDatabase == null || groupsDatabase.size() == 0) {

			// net.crowdloud.shared.Groups groups = new
			// net.crowdloud.shared.Groups();
			// groups.setGroups("Startup Weekend, Hackaway Fridays, Agile Hackathon");
			// SaveGroups.addNew(persistenceManager, groups);

			return null;
		} else {

			return groupsDatabase.get(0);
		}
	}

}
